<template>
  <div class="map-contant">
    <slot></slot>
  </div>
</template>
<script>
// -------------- 初始化 -------------------
import InitMapMixin from "../mixins/initmap"
// -------------- AMap ----------------
import {addSatellite, hiddenSatellite, showSatelite} from "../TileLayer/addSatellite"
import {addWorkPath, updateWorkPath, hidePath} from "../workPath/function";
// -------------- 其他功能 -------------
export default {
  mixins: [InitMapMixin],
  data() {
    return {
      Satellite: undefined,
      pathSimplifierIns: undefined
    }
  },
  mounted() {

    addWorkPath(this.map, this); // 工作路径初始化

    if (this.showSatelite) { // 卫星图初始化
      this.Satellite = addSatellite(this.map);
    }

  },
  props: {
    showSatelite: {
      type: Boolean,
      default: true
    },
    workPath: {
      type: Array,
      default: () => {
        return [
          [100.340417, 27.376994],
          [108.426354, 37.827452],
          [113.392174, 31.208439],
          [124.905846, 42.232876]]
      }
    },
    workMobileName: {
      type: String,
      default: "手机"
    }
  },
  watch: {
    showSatelite: function (val) {
      if (val) {
        showSatelite(this.Satellite);
      } else {
        hiddenSatellite(this.Satellite);
      }
    },
    workPath: function (val) {
      if (val.length === 0) {
        hidePath();
      } else {
        updateWorkPath(this.workMobileName, val);
      }
    }
  }
};
</script>
<style scoped>
.map-contant {
  height: 100%;
  width: 100%;
}
</style>
